import json

import requests


class reque:


    url = ''

    def __init__(self):

        self.url_dict = {'mayson_url':'http://mayson.huimeionline.com/cdss','base_url':'http://mayson.huimeionline.com/cdss','doc_url':'http://doc.huimeionline.com/doc','doc_fe':'http://doc.huimeionline.com', \
                    'doc_online':'http://120.26.223.139','base_url_ame':'http://10.46.74.95:8092','fuxi_data':'http://fuxi.huimeionline.com/node/active/','adminse':'http://admin-se.huimeionline.com/', \
                    'base_url_amc':'http://amc.huimeionline.com','mayson_profile':'http://profile.huimeionline.com/cdss','base_gdms':'http://gdms.huimeionline.com','athena_url':'http://10.117.64.153:8080', \
                    'base_url_sf':'http://10.27.213.55:9092'
                    }


    def get(self,urlName,path,params,headers):

        self.url = str(self.url_dict[urlName])

        res = requests.get(self.url+path,params=params,headers=headers)


        return res.json()



    def post(self,urlName,path,data,headers):

        data_json = json.dumps(data)

        self.url = self.url_dict[urlName]

        res = requests.post(self.url+path,data=data_json,headers=headers)

        return res.json()